<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Username')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-username" class="form-control" name="row[username]" type="text" value="{$row.username|htmlentities}" readonly>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Nickname')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-nickname" class="form-control" name="row[nickname]" type="text" value="{$row.nickname|htmlentities}" readonly>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">权限设置:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="permission-container">
                {volist name="allPermissions" id="module" key="moduleKey"}
                <div class="permission-module">
                    <h4>{$moduleKey|htmlentities}</h4>
                    <div class="permission-actions">
                        {volist name="module" id="action"}
                        <label class="checkbox-inline">
                            <input type="checkbox" name="row[permissions][]" value="{$moduleKey}/{$action.action}" 
                                   {in name="moduleKey.'/'.$action.action" value="$currentPermissions"}checked{/in}>
                            {$action.description|default=$action.action}
                        </label>
                        {/volist}
                    </div>
                </div>
                {/volist}
            </div>
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>

<style>
.permission-container {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 15px;
    border-radius: 4px;
}

.permission-module {
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.permission-module:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.permission-module h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 14px;
    font-weight: bold;
}

.permission-actions {
    margin-left: 20px;
}

.permission-actions label {
    margin-right: 15px;
    margin-bottom: 8px;
    font-weight: normal;
}

.permission-actions input[type="checkbox"] {
    margin-right: 5px;
}
</style>

